package com.company.Demo;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class ZSYzijie04 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int k = scanner.nextInt();
        List<List<Integer>> list = new ArrayList<>();
        for(int i=0;i<k;i++){
            List<Integer> temp = new ArrayList<>();
            temp.add(scanner.nextInt());
            temp.add(scanner.nextInt());
            list.add(temp);
        }
        int x1 = scanner.nextInt();
        int y1 = scanner.nextInt();
        int x2 = scanner.nextInt();
        int y2 = scanner.nextInt();
        List<Integer> flag = new ArrayList<>();
        dfs(x1,y1,x2,y2,new boolean[n+1][m+1],list,flag,0,n,m);
        int min = Integer.MAX_VALUE;
        if(flag.size()==0){
            System.out.println(-1);
        }else{
            for(int i =0;i<flag.size();i++){
                min = Math.min(min,flag.get(i));
            }
            System.out.println(min);
        }
    }
    public static void dfs(int x1,int y1,int x2,int y2,boolean[][] blo,List<List<Integer>> list,List<Integer> temp,int index,int n,int m){
        if(x1==x2&&y1==y2){
            temp.add(index);
        }
        //左上
        if(x1-2>=0&&y1-2>=0&&!blo[x1-2][y1-2]){
            List<Integer> flag = new ArrayList<>();
            flag.add(x1-1);
            flag.add(y1-1);
            if(!list.contains(flag)){
                blo[x1-2][y1-2] = true;
                dfs(x1-2,y1-2,x2,y2,blo,list,temp,index+1,n,m);
            }
        }
        //左下
        if(x1-2>=0&&y1+2<=m&&!blo[x1-2][y1+2]){
            List<Integer> flag = new ArrayList<>();
            flag.add(x1-1);
            flag.add(y1+1);
            if(!list.contains(flag)){
                blo[x1-2][y1+2] = true;
                dfs(x1-2,y1+2,x2,y2,blo,list,temp,index+1,n,m);
            }
        }
        //右上
        if(x1+2<=n&&y1-2>=0&&!blo[x1+2][y1-2]){
            List<Integer> flag = new ArrayList<>();
            flag.add(x1+1);
            flag.add(y1-1);
            if(!list.contains(flag)){
                blo[x1+2][y1-2] = true;
                dfs(x1+2,y1-2,x2,y2,blo,list,temp,index+1,n,m);
            }
        }
        //右下
        if(x1+2<=n&&y1+2<=m&&!blo[x1+2][y1+2]){
            List<Integer> flag = new ArrayList<>();
            flag.add(x1+1);
            flag.add(y1+1);
            if(!list.contains(flag)){
                blo[x1+2][y1+2] = true;
                dfs(x1+2,y1+2,x2,y2,blo,list,temp,index+1,n,m);
            }
        }
    }
}
